Skip to content

Fix/mot17 issues 447 449 450#561

Open
rajdhruvsingh wants to merge 3 commits into
kubeedge:mainfrom
rajdhruvsingh:fix/mot17-issues-447-449-450
Open

Fix/mot17 issues 447 449 450#561
rajdhruvsingh wants to merge 3 commits into
kubeedge:mainfrom
rajdhruvsingh:fix/mot17-issues-447-449-450

Conversation

@rajdhruvsingh

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fixes three bugs in the MOT17/multiedge_inference_bench example with no existing linked PRs, as tracked in the issue summarization #460.

#447 — IndexError / RuntimeError in ReID metric scripts (rank_1.py, rank_2.py, rank_5.py, mAP.py)
The CMC implementation used np.nonzero(matches[i])[0][0] without a length
check, causing an IndexError when a query identity has no match in the
gallery — a valid edge case in standard ReID evaluation splits. Fixed by
checking len(nonzero) == 0 before indexing and skipping such queries.
mAP.py raised an unhandled RuntimeError("No valid query") when the entire
query set was unmatched. Replaced with a LOGGER.warning and a graceful
return 0.0 so the pipeline continues and surfaces a clear diagnostic message
instead of crashing.

#449 — Missing requirements.txt and Docker-only hardcoded workspace paths
The example had no requirements.txt, forcing contributors to discover missing
packages (loguru, motmetrics, mmcv, opencv-python) through repeated
ImportError crashes. Added a requirements.txt with all required packages
and version bounds (motmetrics>=1.2.0, pandas<2.0).
Both tracking_job.yaml and reid_job.yaml hardcoded the workspace path as
/ianvs/multiedge_inference_bench/workspace, which only exists inside the
official ianvs Docker container and causes PermissionError or
FileNotFoundError for all bare-metal and virtualenv users. Replaced with the
relative path ./workspace/multiedge_inference_bench.

#450 — Unconditional import onnx at module scope in multiedge_inference.py
onnx was imported unconditionally at the top of multiedge_inference.py,
making it a hard startup dependency for all MultiedgeInference users even
though it is only required inside _partition(). The MOT17 example never calls
_partition(). Traced via git log -p -- requirements.txt, the current
onnx entry in the root requirements.txt was added incidentally by commit
46340c8 ("Enhanced cloud-edge collaborative inference for llm example") — not
as a deliberate decision for this paradigm. If example-level dependencies are
ever isolated per issue #132, this would regress. Fixed by moving import onnx
to a lazy import inside _partition() only, with a clear ImportError message
for users who attempt to use partitioning without it installed.

Which issue(s) this PR fixes:

Fixes #447
Fixes #449
Fixes #450

Adds parallel execution of test cases to address the unbearable
time overhead when testing multiple hyperparameter groups
sequentially (issue 8).

Changes:
- testcasecontroller.py: add parallel/max_workers params to
  run_testcases(), add _run_testcases_sequential() and
  _run_testcases_parallel() using ThreadPoolExecutor
- testcase.py: fix race condition in _get_output_dir() using
  os.makedirs(exist_ok=True) instead of os.path.exists() loop
- benchmarkingjob.py: add parallel and max_workers config fields
- docs/proposals/chore/parallel_testcase_execution.md: RFC
  proposing phased approach (ThreadPoolExecutor now, Sandbox
  Engine future per PR 526)

ThreadPoolExecutor chosen over ProcessPoolExecutor to avoid
pickling issues with ML model objects. Parallel execution is
opt-in via benchmarkingjob.yaml (parallel: false by default)
for full backward compatibility.

Signed-off-by: dhruvraj319 <dhruv.raj319@gmail.com>
- Remove manual worker count default to avoid OOM on large
  test suites — let ThreadPoolExecutor use its own safe default
- Fix type annotation: max_workers: int | None = None
- Add YAML string coercion for parallel and max_workers params
  to handle parallel: 'false' string values correctly
- Deep copy test cases in parallel mode to prevent race
  conditions from shared test_env and dataset state

Signed-off-by: dhruvraj319 <dhruv.raj319@gmail.com>
@kubeedge-bot kubeedge-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 21, 2026
@kubeedge-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rajdhruvsingh
To complete the pull request process, please assign jaypume after the PR has been reviewed.
You can assign the PR to them by writing /assign @jaypume in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces parallel test case execution using ThreadPoolExecutor, resolves a directory creation race condition, adds lazy importing for onnx, and fixes evaluation bugs in the MOT17 pedestrian tracking example when queries have no matching gallery identities. The feedback highlights several critical issues: the use of PEP 604 union types (int|None) which breaks backward compatibility with Python < 3.10, a potential division-by-zero crash and incorrect denominator calculation in the CMC metrics (rank_1.py, rank_2.py, rank_5.py), and potential memory/CPU overhead from deep-copying entire TestCase objects during parallel execution.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread core/cmd/obj/benchmarkingjob.py Outdated
Comment thread core/testcasecontroller/testcasecontroller.py
…multiedge_inference_bench

- fix(447): guard np.nonzero()[0][0] in rank_1/2/5.py to skip queries
  with no gallery match instead of raising IndexError
- fix(447): replace RuntimeError in mAP.py with LOGGER.warning + return 0.0
  so the pipeline degrades gracefully on empty query sets
- fix(449): add requirements.txt with all missing dependencies (loguru,
  motmetrics, mmcv, opencv-python) and version bounds (motmetrics>=1.2.0,
  pandas<2.0)
- fix(449): replace Docker-only absolute workspace path /ianvs/... with
  relative path ./workspace/... in tracking_job.yaml and reid_job.yaml
- fix(450): move top-level 'import onnx' to lazy import inside _partition()
  so non-partitioning users (MOT17 example) are not forced to install onnx

Signed-off-by: dhruvraj319 <dhruv.raj319@gmail.com>
@rajdhruvsingh rajdhruvsingh force-pushed the fix/mot17-issues-447-449-450 branch from a70209d to 8479182 Compare June 21, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

2 participants